package com.wsjc.common.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.stereotype.Service;

/**
 * 只确认生产者消息发送成功，消费者是否处理成功不做保证
 * @author 93733
 *
 */
@Service("confirmCallBackListener")
public class ConfirmCallBackListener implements ConfirmCallback {


	private Logger logger = LoggerFactory.getLogger(ConfirmCallBackListener.class);
	
	/**
	 * @param correlationData 相关数据
	 * @param ack 
	 * @param cause 
	 */
	@Override
	public void confirm(CorrelationData correlationData, boolean ack, String cause) {
		StringBuilder buf = new StringBuilder(1024); 
		buf.append("RabbitMQ-INFO|ConfirmCallBackListener-confirm()|Params:ack=").append(ack).append(" &cause=").append(cause).append(" &messageId=").append(correlationData.getId()) ;
		logger.info(buf.toString());
		
	}
}
